package dblayer;

import static org.junit.Assert.*;
import modellayer.PartOrder;
import modellayer.Product;

import org.junit.Test;

public class TestPartOrderDB
{
	PartOrderDB PODB = new PartOrderDB();

	@Test
	public void insertTest()
	{
		int testResult = -1;
		
		try
		{
			testResult = PODB.insertPartOrder(new PartOrder(1, 0.0, 5, new Product(1)));
		}
		catch(Exception e)
		{
			fail("Failed to insert PartOrder object in DB. Exception: " +e);
		}
		
		if (testResult == -1)
		{
			fail("Failed to insert PartOrder object in DB.");
		}
	}
	
	@Test
	public void findTest()
	{
		PartOrder po = PODB.findPartOrder(3);
		
		if (po == null)
		{
			fail("Find PartOrder failed.");
		}
	}
	
	@Test
	public void deleteTest()
	{
		try
		{
			PODB.deletePartOrder(3);
		}
		catch(Exception e)
		{
			fail("Failed to insert PartOrder object in DB. Exception: " +e);
		}
	}
	
	@Test
	public void updatetest()
	{
		try
		{
			PODB.updatePartOrder(2, 99, 3);
		}
		catch(Exception e)
		{
			fail("Failed to update PartOrder object in DB. Exception: " +e);
		}
	}
}
